package com.example.bootdemo.mq.consumer;

import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.stereotype.Component;

//@Component
//    @RocketMQMessageListener(  consumerGroup = "${rocketmq.consumer.group}",
//            topic = "${rocketmq.producer.group}",
//            consumeMode= ConsumeMode.CONCURRENTLY,
//            selectorType = SelectorType.TAG,
//            selectorExpression = "tag1")
    public class Tag1Consumer implements RocketMQListener<String>, RocketMQPushConsumerLifecycleListener  {
        @Override
        public void onMessage(String message) {
            System.out.println("Received tag1 message : "+ message);
        }


        @Override
        public void prepareStart(DefaultMQPushConsumer consumer) {
            consumer.setInstanceName("testTopic-tag1");
        }
    }
